(() => {
	window.Log = class Log extends Data {
		static get filepath() {
			return Core.getBaseDir() + '/logs/' + COREVAR.MANIFEST.name + '.log';
		}
		
		static add(content) {
			let fs = nw.require('fs');
			fs.appendFileSync(this.filepath, content, 'utf8');
			return this;
		}
		
		static addLine(str) {
			let datetime = Core.date();
			return this.add(`[${datetime}] ${str}\n`);
		}
	};
	
	function _initlog() {
		let fs = nw.require('fs');
		let path = nw.require('path');
		let dirname = path.dirname(Log.filepath);
		
		if(!fs.existsSync(dirname)) {
			fs.mkdirSync(dirname);
		}
	}
	
	_initlog();
	Core.setToParentWindow('Log', Log);
})();
